import {
  getAction,
  deleteAction,
  putAction,
  postAction
} from '@/api/index'

//获取默认城市
const cityGuess = () => getAction("/v1/cities", {
  type: 'guess'
});
//获取热门城市
const cityHot = () => getAction("/v1/cities", {
  type:'hot'
});
//获取所有城市列表
const cityAll = () => getAction("/v1/cities", {
  type: 'group'
});
//获取当前所在城市
const currentcity = (number) => getAction('/v1/cities/' + number);
//搜索地址
const searchaddress = (cityid, value) => getAction('/v1/pois',{
  type: 'search',
	city_id: cityid,
	keyword: value
});

//获取msite页面的地址信息
const msiteAddress = (geohash) => getAction('/v2/pois/'+geohash,{});
//获取msite页面的食品类型
const msiteFootType = (geohash) => getAction('/v2/index_entry',{
  geohash:geohash,
	group_type: '1',
	'flags[]': 'F'
})
//获取msite页面的商铺列表
const shopList = (latitude,longitude,offset,restaurant_category_id='',restaurant_category_ids='',order_by='',delivery_mode='',supportStr='')=> getAction('/shopping/restaurants',{
  latitude,
  longitude,
  offset,
  limit: '20',
  'extras[]': 'activities',
  keyword: '',
  restaurant_category_id,
  'restaurant_category_ids[]': restaurant_category_ids,
  order_by,
  'delivery_mode[]': delivery_mode + supportStr
})




//获取图片验证码
const getcaptchas = () => postAction('/v1/captchas',{});
//账号密码登录
const getLogin = (username, password, captcha_code) => postAction('/v2/login',{
  username, 
  password, 
  captcha_code
});
//短信验证码
const phoneCode = (phone) => postAction('/v4/mobile/verify_code/send',{
  mobile: phone,
	scene: 'login',
	type: 'sms'
});
//手机号登录
const phoneLogin = (code, mobile, validate_token) => postAction('/v1/login/app_mobile',{
  code, 
  mobile,
  validate_token
});


export{
  cityGuess,
  cityHot,
  cityAll,
  currentcity,
  searchaddress,
  msiteAddress,
  msiteFootType,
  shopList,

  getLogin,
  getcaptchas,
  phoneCode,
  phoneLogin,
  
}